package leetcode.ArrayAndString;

public class ReverseString {


    /**
     * 反转字符串
     * @param s
     * @return
     */
    public static String reverseString(String s) {
        int i = 0;
        int j = s.length()-1;
        char[] ch = s.toCharArray();
        while(i<j){
            swap(ch,i,j);
            i++;
            j--;
        }
        return new String(ch);
    }
    private static void swap(char[] ch,int i,int j){
        char temp = ch[i];
        ch[i] = ch[j];
        ch[j] = temp;
    }

    public static void main(String[] args) {
        System.out.println(reverseString("12 ,345 ,6"));
    }


}
